#ifndef MICROBABASSE_H
#define MICROBABASSE_H

#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlRelationalTableModel>
#include <QItemSelectionModel>
#include <QStandardItemModel>
#include <moneydelegate.h>
#include <choixconso.h>
#include <choixpg.h>
#include <consoimport.h>
#include <promsmodel.h>
#include <connexionbdd.h>

#include <QKeyEvent>
#include <QInputDialog>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>

namespace Ui {
class MicroBabasse;
}

class MicroBabasse : public QWidget
{
    Q_OBJECT

public:
    explicit MicroBabasse(QWidget *parent = 0);
    ~MicroBabasse();

public slots:
    void importerConso(int id, QString nom, double prix);

    void nouveauPg();
    void abandonner();
    void identifierPg(int fams, QString proms);
    void bucquer(QList<int> liste);
    void majProms(const QItemSelection & selected, const QItemSelection & deselected);

protected:
    void keyPressEvent(QKeyEvent *e);

private slots:
    void on_buttonFermer_clicked();

    void on_buttonNouveau_clicked();

    void on_buttonOuvrir_clicked();

    void on_buttonConsoAjouter_clicked();

    void on_buttonConsoRetirer_clicked();

    void on_buttonConsoImport_clicked();

    void on_buttonSupprimer_clicked();

    void on_buttonDemarrer_clicked();

    void on_buttonAppliquer_clicked();

private:
    Ui::MicroBabasse *ui;

    QSqlDatabase db;
    QSqlDatabase microdb;

    QSqlTableModel *modelConsos;
    PromsModel *modelProms;
    QSqlRelationalTableModel *modelBucquage;

    ChoixConso *choixconso;
    ChoixPg *choixpg;
    ConsoImport *import;

    int famstmp;
    QString promstmp;

    QString cheminbase;

    bool fichierOuvert;

    void connecterTemp();
    void reloadProms();


};

#endif // MICROBABASSE_H
